//
//  HTHeaderCollectionView.m
//  TruckDriver
//
//  Created by Ting Han on 2017/10/12.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTHeaderCollectionView.h"

@interface HTHeaderCollectionView()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detialLabel;
@property (weak, nonatomic) IBOutlet UIImageView *tipsImageView;
@property (weak, nonatomic) IBOutlet UIView *lineTop;
@property (weak, nonatomic) IBOutlet UIView *lineBottom;

@property (nonatomic,assign) BOOL isChosed;

@end

@implementation HTHeaderCollectionView

- (void)setHeaderModel:(HTTruckHeaderModel *)headerModel{
    _headerModel = headerModel;
    self.titleLabel.text = headerModel.title;
    if (headerModel.type == 0) {
        self.detialLabel.hidden = NO;
        self.tipsImageView.hidden = YES;
        self.lineTop.hidden = YES;
        self.lineBottom.hidden = YES;
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        return;
    }
    if (headerModel.type == 1) {
        self.detialLabel.hidden = YES;
        self.tipsImageView.hidden = YES;
        self.lineTop.hidden = YES;
        self.lineBottom.hidden = YES;
         self.titleLabel.font = [UIFont systemFontOfSize:13];
        return;
    }
    if (headerModel.type == 2) {
        self.detialLabel.hidden = YES;
        self.tipsImageView.hidden = NO;
        self.lineTop.hidden = NO;
        self.lineBottom.hidden = NO;
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        return;
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.isChosed = NO;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHeadView:)];
    [self addGestureRecognizer:tapGesture];
    
}
//点击事件
- (void)tapHeadView:(id)sender{
    if (!(_headerModel.type == 2)) {
        return;
    }
    self.isChosed = !self.isChosed;
    if (self.isChosed) {
        self.tipsImageView.image = [UIImage imageNamed:@"cashier_select_pressed"];
    }else{
         self.tipsImageView.image = [UIImage imageNamed:@"cashier_select_normal"];
    }
    if (self.headerViewBlock) {
        self.headerViewBlock(self.isChosed);
    }
}
- (void)setIsSelectedOn:(BOOL)isSelectedOn{
    _isSelectedOn = isSelectedOn;
    if (isSelectedOn) {
        self.isChosed = YES;
        self.tipsImageView.image = [UIImage imageNamed:@"cashier_select_pressed"];
    }else{
        self.isChosed = NO;
        self.tipsImageView.image = [UIImage imageNamed:@"cashier_select_normal"];
    }
}
@end
